using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Spire.Presentation.Drawing;

namespace Spire.Presentation.Demo
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnRun_Click(object sender, EventArgs e)
        {
            //create PPT document
            Presentation presentation = new Presentation();

            //set the size of slides
            presentation.SlideSize.Size = new SizeF(500, 600);

            //set background Image
            string ImageFile = @"..\..\..\..\..\..\Data\bg.png";
            RectangleF rect = new RectangleF(0, 0, presentation.SlideSize.Size.Width, presentation.SlideSize.Size.Height);
            presentation.Slides[0].Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile, rect);
            presentation.Slides[0].Shapes[0].Line.FillFormat.SolidFillColor.Color = Color.FloralWhite;

            //append new shape
            IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 70, 300, 300));
            shape.ShapeStyle.LineColor.Color = Color.White;
            shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None;
            
            //add text to shape
            shape.AppendTextFrame("The sample demonstrates how to set the size of slides.");

            //append new paragraph
            shape.TextFrame.Paragraphs.Append(new TextParagraph());
            
            //add text to paragraph
            shape.TextFrame.Paragraphs[1].TextRanges.Append(new TextRange("With Spire.Office for .NET, developers can create a wide range of applications. It enables developers to open, create, modify, Convert, Print, View MS Word, Excel, PDF documents. Furthermore, it allows users to export data to popular files such as MS Word/Excel/RTF/Access, PDF, XPS, HTML, XML, Text, CSV, DBF, Clipboard, SYLK, etc."));

            //set the Font
            foreach (TextParagraph para in shape.TextFrame.Paragraphs)
            {
                para.TextRanges[0].LatinFont = new TextFont("Arial Rounded MT Bold");
                para.TextRanges[0].Fill.FillType = FillFormatType.Solid;
                para.TextRanges[0].Fill.SolidColor.Color = Color.Black;
                para.Alignment = TextAlignmentType.Left;
                para.Indent = 35;
            }

            //save the document
            presentation.SaveToFile("PageProperty.pptx", FileFormat.Pptx2010);
            System.Diagnostics.Process.Start("PageProperty.pptx");
        }
    }
}